# Contributor: Newbyte <newbyte@disroot.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=py3-pydantic
pkgver=2.6.4
pkgrel=1
pkgdesc="Data parsing and validation using Python type hints"
url="https://github.com/samuelcolvin/pydantic"
arch="noarch"
license="MIT"
depends="py3-typing-extensions py3-annotated-types py3-pydantic-core"
makedepends="py3-gpep517 py3-hatchling py3-wheel py3-hatch-fancy-pypi-readme"
checkdepends="py3-hypothesis py3-pytest py3-pytest-mock py3-pytest-benchmark py3-dirty-equals py3-cloudpickle py3-faker"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/samuelcolvin/pydantic/archive/refs/tags/v$pkgver.tar.gz
	pytest8.patch"
builddir="$srcdir/pydantic-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	# needs pydantic-email which is not packaged
	local k="not test_fastapi_startup_perf"

	# fails with pytest 8
	# https://github.com/pydantic/pydantic/issues/9025
	k="$k and not test_config_class_is_deprecated"
	k="$k and not test_config_class_attributes_are_deprecated"
	k="$k and not test_field_include_deprecation"
	k="$k and not test_deprecated_module"
	k="$k and not test_use_bare"
	k="$k and not test_use_no_fields"
	k="$k and not test_validator_bad_fields_throws_configerror"
	k="$k and not test_assert_raises_validation_error"

	.testenv/bin/python3 -m pytest --benchmark-disable -k "$k" \
		--ignore=tests/test_docs.py
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
dd3cb35d6b062649f30ede0f32740d02e53383d231b3c92e9a6aec26d8fa07a141d22162b2e08efa49ea7321411891f9a34cb5bc2e05186c4069f57cec6e51d2  py3-pydantic-2.6.4.tar.gz
6860357fc5a1c83c66e1ec697f695c7041593d71c607e03d3388f7225b5c3569b7ad51257dd174d2c34b5ccffded0adc0552b39b60d65808a5733363be429872  pytest8.patch
"
